﻿function getData(procedureName, params, returnFun, secured, baseUrl, returnParam, returnParam2) {
    if (baseUrl == undefined || baseUrl == '')
        baseUrl = getBaseUrl();
    if (secured == true) {
        if (baseUrl.indexOf('https') == -1)
            baseUrl = baseUrl.replace('http', 'https');
    }
    $.ajax({
        url: baseUrl + procedureName + '?' + params,
        success: function (data)
        {
            returnFun(data, returnParam, returnParam2);
        }
    });
}

function getBaseUrl()
{
    return location.href.substring(0, location.href.indexOf('/', 7));
}

function login(username, password, returnFun) {
    var params = "username=" + username + "&password=" + password;
    getData('Login', params, returnFun, true);
}

function initNav(selector, group, header) {
    //selector.find(group).hide().first().show();

    selector.find(header).click(function () {
        $(this).next(group).slideToggle();
        selector1Scrollbar.resize();
    });
}

var selector1Scrollbar;
var selector2Scrollbar;
var selector3Scrollbar;
function addScrollbars(selector1, selector2, selector3) {
    selector1Scrollbar = $(selector1).niceScroll();
    selector2Scrollbar = $(selector2).niceScroll();
    selector3Scrollbar = $(selector3).niceScroll();
}

function getHtmlInputTypeFromSqlDatatype(datatype) {
    return 'text';
}

function getSerializedFormString(form) {
    var serializedForm = $(form).serializeArray();
    var serializedString = "";
    for (var item in serializedForm) {
        serializedString += "&" + serializedForm[item].name + "=" + serializedForm[item].value;
    }

    return serializedString.replace("&", "");
}